#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <pthread.h>

int main(int argc, char const *argv[])
{
    struct sockaddr_in server_addr;

    memset(&server_addr,0,sizeof(server_addr)); 

    server_addr.sin_family = AF_INET;
    server_addr.sin_addr.s_addr = htonl(100);
    server_addr.sin_port = htons(6666);
    

    printf("服务端地址是 %d %d\n",ntohl(server_addr.sin_addr.s_addr),ntohs(server_addr.sin_port));


    // 字符串格式直接帮助我们转化为网络字节序的ip地址
    // inet_aton();
    inet_pton(AF_INET,"192.168.10.150",&server_addr.sin_addr);
    printf("服务端地址是 %s %d\n",inet_ntoa(server_addr.sin_addr),ntohs(server_addr.sin_port));

    printf("网络号 %d 本机地址 %d\n",inet_netof(server_addr.sin_addr),inet_lnaof(server_addr.sin_addr));

    printf("%s",inet_ntoa(inet_makeaddr(inet_netof(server_addr.sin_addr),inet_lnaof(server_addr.sin_addr))));

    return 0;
}
